package view.frontend.order;

import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import javax.swing.JPanel;
import view.ViewHandler;
import view.ViewSingleton;
import view.menu.MenuLabel;

/**
 * 
 * @author Sonny Sandberg
 */
public class OrderContainer 
{
    private JPanel orderContainerPanel;
    private Order order;
    private OrderSearch orderSearch;
    private OrderSearchList orderSearchList;
    private OrderPayment orderPayment;
    private NewOrderButtonPanel newOrderButtonPanel;

    public OrderContainer()
    {
        order = new Order(this);
        order.getPanel().setVisible(false);
        
        orderContainerPanel = new JPanel(null);
        orderContainerPanel.setBounds(95, 320, 900, 500);
        orderContainerPanel.setOpaque(false);
        orderContainerPanel.addComponentListener(new ComponentAdapter() 
        {
            @Override
            public void componentShown(ComponentEvent evt)
            {
                ArrayList<MenuLabel> menuLabels = ViewSingleton.getSingletonObject().getMenuLabels();
                for (MenuLabel value : menuLabels)
                {
                    if (value.getMenuLabelText().equals("ORDRE"))
                    {
                        value.setBackgroundColor();
                    }
                }
                        
                ViewHandler.setPageTitle("Ordre");
                ViewHandler.toggleAllsView("pageTitle", true);
            }
        });

        
        orderPayment = new OrderPayment(this);
        orderPayment.getPanel().setVisible(false);
        
        orderSearch = new OrderSearch(this);
        orderSearch.getPanel().setVisible(true);
        
        orderSearchList = new OrderSearchList(this);
        orderSearchList.getPanel().setVisible(true);
        
        newOrderButtonPanel = new NewOrderButtonPanel(this);
        newOrderButtonPanel.getPanel().setVisible(true);
        
        orderContainerPanel.add(orderPayment.getPanel());
        orderContainerPanel.add(order.getPanel());
        orderContainerPanel.add(orderSearch.getPanel());
        orderContainerPanel.add(orderSearchList.getPanel());
        orderContainerPanel.add(newOrderButtonPanel.getPanel());
        orderContainerPanel.setVisible(false);
    }

    public Order getOrder()
    {
        return order;
    }

    public OrderSearch getOrderSearch()
    {
        return orderSearch;
    }

    public OrderSearchList getOrderSearchList()
    {
        return orderSearchList;
    }

    public OrderPayment getOrderPayment()
    {
        return orderPayment;
    }

    public NewOrderButtonPanel getNewOrderButtonPanel()
    {
        return newOrderButtonPanel;
    }

    public JPanel getPanel()
    {
        return orderContainerPanel;
    }
}